<!DOCTYPE html>

<html>
    <head>
        <title>Agenda</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="css/bootstrap.css" rel="stylesheet">
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
  	<link href="css/stilo.css" rel="stylesheet">
    <link href="css/agenda.css" rel="stylesheet">
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="js/html5shiv.js"></script>
        <![endif]-->
    </head>
    <body>
       <div class="container">
           <?php include "topo.html"; ?>
           <?php include "menu.php"; ?>
           
           
		<section><!-- ----------------------------------------Inicio do Conteudo----------------------------------- -->
			<div id="conteudo">
				<div class="row-fluid">
					<div class="span12">
						<div class="titulo">
                                                    <p><b>Agenda do(a) Especialista: <?php echo $nomeprofissional; ?></b></p>
						</div>
						<div class="bordas">
                                                    <div class="span3">
                                                        <?php

                                                              print '<table class="tabela" >';//construção do calendario

                                                              print '<tr>';

                                                              print '<td class="mes"><a href="?pg=ListarAgenda&data='.$primeiro.'/'.$mes_ant.'/'.$ano_ant.'" title="Mês anterior">  &laquo; </a></td>';/*mês anterior*/

                                                              print '<td class="mes" colspan="5">'.$mes.'/'.$ano.'</td>';/*mes atual e ano*/

                                                              print '<td class="mes"><a href="?pg=ListarAgenda&data='.$primeiro.'/'.$mes_prox.'/'.$ano_prox.'" title="Próximo mês">  &raquo; </a></td>';/*Proximo mês*/

                                                              print '</tr><tr>';

                                                              print '<td class="sem">D</td>';//printar os dias da semana

                                                              print '<td class="sem">S</td>';

                                                              print '<td class="sem">T</td>';

                                                              print '<td class="sem">Q</td>';

                                                              print '<td class="sem">Q</td>';

                                                              print '<td class="sem">S</td>';

                                                              print '<td class="sem">S</td>';

                                                              print '</tr><tr>';

                                                              $dt = 1;

                                                              if($branco > 0){

                                                                  for($x = 0; $x < $branco; $x++){

                                                                       print '<td>&nbsp;</td>';/*preenche os espaços em branco*/

                                                                      $dt++;

                                                                  }

                                                              }

                                                              for($i = 1; $i <= $n; $i++ ){

                                                              if($dt == 1){/*imprime os domingos*/

                                                                  print '<td class="dom">';

                                                                  print $i;

                                                                  print '</td>';

                                                                  $dt++;

                                                              }else{/*imprime os dias normais*/

                                                                  print '<td class="td">';

                                                                  print '<a href="?pg=ListarAgenda&data='.$i.'/'.$month.'/'.$ano.'">'.$i.'</a>';

                                                                  print '</td>';

                                                                  $dt++;

                                                                      }

                                                              if($dt > 7){/*faz a quebra no sabado*/

                                                              print '</tr><tr>';

                                                              $dt = 1;

                                                              }
                                                              }


                                                          print '</tr>';

                                                          print '</table>';

                                                         
                                                          $calendario = $dia.'/'.$month.'/'.$ano;
                                                          
                                                          ?>
                                                        </br></br>


                                                    </div>
                                                    <div class="span9">
                                                        Lista de consulta
														<div class="row-fluid">                                                      
														<div class="span12 table-responsive">
                                                        <table class="table">
                                                            <tr>
                                                                <th colspan="4">Data: <?php echo $calendario; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th>Codigo</th>
                                                                <th>Nome</th>
                                                                <th>Hora</th>
                                                                <th>Atender</th>
                                                            </tr>
                                                            <?php foreach ($listando as $aux) {
                                                                date_default_timezone_set("America/Campo_Grande");
                                                                $data = date('Y-m-d');
                                                                $usuario = new Usuario();
                                                                $resultado = $usuario->find($aux->age_usu_id);
                                                            echo '                                                             
                                                                                                                      
                                                            <tr>
                                                                <td>'.$aux->age_usu_id.'</td>
                                                                <td>'.$resultado->usu_nome.'</td>
                                                                <td>'.$aux->age_hora.'</td>';
                                                            if(strtotime($aux->age_data) == strtotime($data)){
                                                            
                                                              echo '<td><a href="index.php?pg=AtenderPaciente&id='.$aux->id.'" class="btn">Atender </a></td>';
                                                            }else {
                                                              echo '<td><a href="#" class="btn">Indisponivel</a></td>';  
                                                            }
                                                           echo '</tr>';
                                                            }
                                                            ?>
                                                        </table>
														</div>
														</div>
                                                        
                                                    </div>    
                                                    </div>
						</div>
					</div>	
				</div>
			</div> <!-- Fim da linha conteudo -->
		</section><!-- ----------------------------------------fim do Conteudo----------------------------------- -->

           
           <?php include "rodape.html"; ?>
           
           
       </div><!-- fim da div container -->    
        
        
    <!-- Arquivos Javascripts ================================================== -->
    <script src="js/jquery-1.10.2.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jquery.validate.js"></script>
    <script src="js/sonumeros.js"></script>
    <script src="js/popup.js"></script>
    <script src="js/jquery.maskedinput.js"></script>
    <script src="js/mascaras.js"></script>
    <script src="js/validaformagenda.js"></script>
    </body>
</html>

